import java.util.List;

import ocumed.persistenz.hibernate.OcPatient;

import org.hibernate.criterion.Restrictions;

/**
 * find all patients by name, case-insensitive
 * 
 * @param string
 * @return
 */
public List<OcPatient> findByName(String criteria);
}

    /**
     * find all OcPatient name filtered 
     * ignore case
     */
    @SuppressWarnings("unchecked")
    public List<OcPatient> findByName(String qry) {        
        log.debug("finding all OcPatient instances using filter: " + qry);
        try {
            List<OcPatient> results = sessionFactory
                    .getCurrentSession()
                    .createCriteria(OcPatient.class)
                    .add(Restrictions.or(
                            Restrictions.ilike("patientvorname", "%"+qry+"%"),
                            Restrictions.ilike("patientnachname", "%"+qry+"%")
                    ))
                    .list();
            log.debug("finding filtered OcPatient successful, result size: "
                    + results.size());
            return results;
        } catch (RuntimeException re) {
            log.error("finding filtered OcPatient failed", re);
            throw re;
        }
    }